"""
用户 Request VO
"""

from config import settings
from models import RequestBase
from my_typing import *
from utils.data_utils.special import ObjectIdStr
from utils.validator_utils.pydantic_validator.field import (
    BodyCharField,
    BodyIntegerField,
    PathCharField,
)


class UserCheckRequest(RequestBase):
    """ 用户 | 检查 | 请求 """

    union_username: str = BodyCharField(..., title="用户名/手机号/邮箱", min_length=3, max_length=20)


class UserRegisterRequest(RequestBase):
    """ 用户 | 注册 | 请求 """

    confirm_password: str = BodyCharField(..., title="确认密码", min_length=3, max_length=20)
    nickname: str = BodyCharField(..., title="昵称", min_length=3, max_length=20)
    password: str = BodyCharField(..., title="密码", min_length=3, max_length=20)
    username: str = BodyCharField(..., title="用户名", min_length=3, max_length=20)


class UserLoginRequest(UserCheckRequest):
    """ 用户 | 登录 | 请求 """

    password: str = BodyCharField(..., title="密码", min_length=3, max_length=20)
    token_max_age: int = BodyIntegerField(
        settings.SECURITY.TOKEN_MAX_AGE,
        title="Token 有效时间（天）",
        min_value=1,
        max_value=30,
    )


class UserPathField:
    """ 用户 | 路径 | 字段 """

    user_id: ObjectIdStr = PathCharField(..., title="用户 ID")


class UserDetailRequest(RequestBase):
    """ 用户 | 详情 | 请求 """

    user_id: ObjectIdStr = UserPathField.user_id


class UserChangePasswordRequest(RequestBase):
    """ 用户 | 修改密码 | 请求 """

    old_password: str = BodyCharField(..., title="旧密码", min_length=3, max_length=20)
    new_password: str = BodyCharField(..., title="新密码", min_length=3, max_length=20)


class UserUpdateRequest(RequestBase):
    """ 用户 | 更新 | 请求 """

    avatar_id: ObjectIdStr = BodyCharField(..., title="头像 ID")
    email: StrOrNone = BodyCharField(None, title="邮箱", max_length=64)
    nickname: str = BodyCharField(..., title="昵称", min_length=3, max_length=20)
    phone: StrOrNone = BodyCharField(None, title="手机号", min_length=11, max_length=11)
